// pages/user/come_go.js
import { User } from '../../model/user';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    one: [],
    two: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    wx.showLoading({
      title: '加载中',
    });
    this.getUserPrivacyList();
  },
  async getUserPrivacyList() {
    const res = await User.getUserPrivacyList();
    this.setData({
      one: res.one,
      two: res.two,
    });
    wx.hideLoading();
  },
  openWin(e) {
    wx.navigateTo({
      url: '../blind_date/details?id='+e.currentTarget.dataset.id,
    })
  },
  async updateData(e) {
    const data = {
      id: e.currentTarget.dataset.id
    }
    wx.showLoading({
      title: '加载中',
    });
    const res = await User.updateStatus(data);
    if(res) {
      this.getUserPrivacyList();
    } else {
      wx.hideLoading();
    }
  }
})